﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JBookStore.Data.Models
{
    public class Book
    {
        public int ID { set; get; }
        public string ISBN { set; get; }
        public string BookName { set; get; }
        public string Author { set; get; }
        public decimal Price { set; get; }
        public string Publisher { set; get; }
        public string BookPic { set; get; }
        public int CategoryID { set; get; }
        public string Detail { set; get; }

        public Book() { }

        public Book(string ISBN,string name,string author,
                        decimal price,string publisher,int categoryID,string description)
        {
            this.ISBN=ISBN;
            this.BookName=name;
            this.Author=author;
            this.Price=price;
            this.Publisher=publisher;
            this.CategoryID=categoryID;
            this.Detail=description;
        }

        #region Object overrides
        public override bool Equals(object obj)
        {
            if (obj is Book)
            {
                Book compareTo = (Book)obj;
                return compareTo.ID == this.ID;
            }
            else
            {
                return base.Equals(obj);
            }
        }

        public override string ToString()
        {
            return this.BookName;
        }

        public override int GetHashCode()
        {
            return this.ID.GetHashCode();
        }
        #endregion
    }
}
